package com.yc.hotel.controller;

import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yc.hotel.dto.UserInfoDTO;
import com.yc.hotel.enums.ResultEnum;
import com.yc.hotel.util.ConstantInfo;
import com.yc.hotel.vo.ResultVO;

@RestController
@RequestMapping("/user")
public class UserInfoFeignController {

	
	@GetMapping("/check")
	private ResultVO check(HttpSession session) {
		Object obj = session.getAttribute(ConstantInfo.CURRENTMEMBERINFO);
		if (obj == null) {
			return new ResultVO(ResultEnum.LOGIN_ERROR);
		}
		UserInfoDTO user = (UserInfoDTO)obj;
		return new ResultVO(ResultEnum.SUCCESS, user);
	}
	@GetMapping("/out")
	private ResultVO out(HttpSession session) {
		session.removeAttribute(ConstantInfo.CURRENTMEMBERINFO);
		
		return new ResultVO(ResultEnum.SUCCESS);
	}
	
}
